home *** CD-ROM | disk | FTP | other *** search
/ Cheet Sheets / Cheet Sheets.iso / title.mst < prev    next >
Encoding:
Text File  |  1995-06-12  |  15.0 KB  |  475 lines

  1. '**************************************************************************
  2. '*
  3. '* TITLE.MST - Viewer Runtime Setup Script
  4. '*
  5. '* CUSTOMIZING TITLE.MST
  6. '*
  7. '* For a simple Setup routine, you just need to assign values to the 
  8. '* series of variables following the heading "Setup Variables". This
  9. '* script also provides for the following more-advanced options, which
  10. '* are supported by subroutines located later in this script:
  11. '*
  12. '* Option                                         See Subroutine
  13. '* ------------------------------------------     ---------------------
  14. '* Install more than one .MVB file                ModifyViewerIni
  15. '* Install Help title                             ModifyViewerIni
  16. '* Install custom DLLs                            ModifyViewerIni
  17. '* Install multiple Program Manager items         ModifyProgramManager
  18. '* Display a custom icon with the ProgMan item    ModifyProgramManager
  19. '* Install custom fonts                           RegisterCustomFonts
  20. '* Install Video for Windows runtime files        RegisterDrivers
  21. '*
  22. '* Each customization note starts with the heading CUSTOMIZATION.
  23. '*
  24. '**************************************************************************
  25.     
  26.     '' Global variables
  27.  
  28.     GLOBAL TitleShortName$
  29.     GLOBAL TitleLongName$
  30.     GLOBAL MVBFileName$
  31.     GLOBAL PromptForPath%
  32.     GLOBAL DefaultPath$
  33.     GLOBAL ProgManGroup$
  34.     GLOBAL ProgManItem$
  35.     GLOBAL Dest$   ''default destination directory
  36.  
  37.     '' ****************************************************************
  38.     '' ** Setup Variables
  39.     '' ****************************************************************
  40.  
  41.     '' Set the following string to a short form of the title name
  42.     '' (for example, "Gallery")
  43.     
  44.     TitleShortName$ = "CheetSheets"
  45.     
  46.     '' Set the following string to a long form of the title name
  47.     '' (for example, "Viewer 2.0 Gallery")
  48.     
  49.     TitleLongName$ = "CheetSheets"
  50.         
  51.     '' Set the following variable to the name of the MVB file, without 
  52.     '' the filename extension (for example, "GALLERY")
  53.         
  54.     MVBFileName$ = "monarch"
  55.         
  56.     '' The following variable determines whether Setup prompts the user
  57.     '' to specify a directory in which to install title files. (Files
  58.     '' to be installed on the hard disk must be listed in the TITLE.INF 
  59.     '' file under the [Installed Title Files] section.) Specify one of
  60.     '' the following values:
  61.     ''
  62.     '' 0    Install title files in the Windows directory (default setting).
  63.     ''      This is an appropriate setting if you have a limited number
  64.     ''      of files to copy (for example, a single custom icon or DLL).
  65.     ''
  66.     '' 1    Display a dialog box to prompt the user for a directory in 
  67.     ''      which to install files
  68.         
  69.     PromptForPath% = 1
  70.         
  71.     '' If you have specified 1 in PromptForPath%, set the following 
  72.     '' variable to the default path that will be displayed in the dialog
  73.     '' box (for example, "C:\GALLERY").
  74.         
  75.     DefaultPath$ = "C:\MONARCH"
  76.     
  77.     '' Set the following variable to the name of the program manager 
  78.     '' group you would like to create (for example, "Viewer 2.0 Gallery")
  79.         
  80.     ProgManGroup$ = "Bureau Multimedia"
  81.     
  82.     '' Set the following variable to the caption of the program manager 
  83.     '' item for your title (for example, "Gallery")
  84.         
  85.     ProgManItem$ = "CheetSheets"
  86.     
  87.     '***********************************************************************
  88.     '** Mainline
  89.     '***********************************************************************
  90.  
  91.     GLOBAL CUIDLL$
  92.  
  93.     '' Include files
  94.     '$INCLUDE 'setupapi.inc'
  95.     
  96.     '' Custom UI dll
  97.     CUIDLL$ = "mscuistf.dll"
  98.     
  99.     '' Dialog ID's
  100.     CONST DESTPATH      = 1000
  101.     CONST APPHELP       = 2000
  102.     CONST TOOBIG        = 3000
  103.     CONST BADPATH       = 4000
  104.     CONST SUCCESS       = 5000
  105.     
  106.     '' Bitmap ID
  107.     CONST LOGO = 1
  108.     
  109.     '' Functions and subroutines
  110.     DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  111.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  112.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  113.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  114.     DECLARE SUB RegisterFont(fontfile$, fontname$)
  115.     DECLARE SUB ModifyViewerIni(szTitleDir$)
  116.     DECLARE SUB RegisterCustomFonts
  117.     DECLARE SUB ModifyProgramManager
  118.     DECLARE SUB ShowSuccess
  119.     DECLARE SUB RegisterDrivers
  120.     
  121.     '' The following statement turns size checking off. Set it to scmOnFatal 
  122.     '' to enable size checking, where Setup will compare the disk file size 
  123.     '' with the INF file size and report an error if they are not the same.
  124.     
  125.     i% = SetSizeCheckMode(scmOff)
  126.     
  127.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  128.     '' alter the banner bitmap.
  129.     
  130.     SetTitle "Bureau Title Setup"
  131.     SetBitmap CUIDLL$, LOGO 
  132.     
  133.     '' Read in the INF file.
  134.     
  135.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
  136.     
  137.     '' Decide where to put title files
  138.     IF PromptForPath% = 1 THEN
  139.         szTitleDir$ = GetTitleDir(DefaultPath$)
  140.         IF szTitleDir$ = "" THEN
  141.             GOTO QUIT
  142.         ENDIF
  143.     ELSE
  144.         szTitleDir$ = GetWindowsDir()
  145.     ENDIF   
  146.     
  147.     '' Copy files
  148.     IF CopyFiles(szTitleDir$) = 0 THEN
  149.         GOTO QUIT
  150.     ENDIF
  151.  
  152.     '' Create the MVIEWER2.EXE MVB association 
  153.     CreateIniKeyValue "WIN.INI", "Extensions", "MVB", "mviewer2.exe", cmoNone
  154.  
  155.     '' Register in VIEWER.INI
  156.     ModifyViewerIni szTitleDir$
  157.  
  158.     '' Register custom fonts
  159.     RegisterCustomFonts
  160.  
  161.     '' Register drivers
  162.     RegisterDrivers
  163.     
  164.     '' Modify Program Manager
  165.     ModifyProgramManager    
  166.     
  167.     '' Success dialog
  168.     '' ShowSuccess
  169.     
  170. QUIT:
  171.     
  172.     END
  173.     
  174.  
  175. '*************************************************************************
  176. '** Purpose:
  177. '**     Prompts the user for a path for the title files
  178. '** Arguments:
  179. '**     szDefault$ - default path
  180. '** Returns:
  181. '**     New valid path name, or "" if the user quit.
  182. '*************************************************************************
  183.  
  184. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  185.  
  186.     SetSymbolValue "String", TitleShortName$
  187.     SetSymbolValue "EditTextIn", szDefault$
  188.     SetSymbolValue "EditFocus", "ALL"
  189.  
  190.     GETPATH:
  191.  
  192.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  193.  
  194.     IF sz$ = "CONTINUE" THEN
  195.         szTitleDir$ = GetSymbolValue("EditTextOut")
  196.         IF IsDirWritable(szTitleDir$) = 0 THEN
  197.  
  198.             BADPATH:
  199.  
  200.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  201.             IF sz$ = "REACTIVATE" THEN
  202.                 GOTO BADPATH
  203.             END IF
  204.             UIPop 1
  205.             GOTO GETPATH
  206.         END IF
  207.         UIPop 1
  208.         CreateDir szTitleDir$, cmoNone
  209.         Dest$ = szTitleDir$
  210.  
  211.     ELSEIF sz$ = "REACTIVATE" THEN
  212.         GOTO GETPATH
  213.  
  214.     ELSE
  215.         szTitleDir$ = ""
  216.  
  217.     END IF
  218.  
  219.     GetTitleDir = szTitleDir$
  220.  
  221. END FUNCTION
  222.  
  223.  
  224. '*************************************************************************
  225. '** Purpose:
  226. '**     Copies the files in the INF file
  227. '** Arguments:
  228. '**     szTitleDir$ - destination directory for the title files
  229. '** Returns
  230. '**     1 if files were copied, 0 otherwise
  231. '*************************************************************************
  232.  
  233. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  234.  
  235.     '' Add all system files to the copy list
  236.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()    
  237.     '' Add all of the title files to the copy list
  238.     AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  239.     
  240.     '' Check size
  241.     szExtras$ = "Extra"
  242.     szCosts$ = "Costs"
  243.     szNeededs$ = "Neededs"
  244.     FOR i% = 1 TO 26 STEP 1
  245.         AddListItem szExtras$, "0"
  246.     NEXT i%
  247.     
  248.     '' We assume that VIEWER.INI will take another 4K
  249.     ReplaceListItem szExtras$, ASC(MID$(GetWindowsDir(), 1, 1)) - ASC("A") + 1, STR$(4096)
  250.     
  251.     '' Get amount of space required
  252.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  253.     
  254.     '' Put up a message if there is not enough space
  255.     FOR i% = 1 TO 26 STEP 1
  256.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  257.     
  258.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  259.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  260.     
  261.             TOOBIG:
  262.     
  263.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  264.             IF sz$ = "REACTIVATE" THEN
  265.                 GOTO TOOBIG
  266.             END IF
  267.             UIPop 1
  268.             CopyFiles = 0
  269.             GOTO DONTCOPY
  270.         END IF
  271.     NEXT i%
  272.     
  273.     '' Copy the files
  274.     CopyFilesInCopyList
  275.     
  276.     CopyFiles = 1
  277.  
  278. DONTCOPY:
  279.  
  280. END FUNCTION
  281.  
  282.  
  283. '*************************************************************************
  284. '** Purpose:
  285. '**     Puts up a success dialog
  286. '*************************************************************************
  287.  
  288. SUB ShowSuccess STATIC
  289.  
  290.     SUCCESS:
  291.     
  292.     SetSymbolValue "String1", TitleShortName$
  293.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  294.     IF sz$ = "REACTIVATE" THEN
  295.         GOTO SUCCESS
  296.     END IF
  297.     UIPop 1
  298.     
  299. END SUB
  300.  
  301.  
  302. '*************************************************************************
  303. '** Purpose:
  304. '**     Appends a file name to the end of a directory path,
  305. '**     inserting a backslash character as needed.
  306. '** Arguments:
  307. '**     szDir$  - full directory path (with optional ending "\")
  308. '**     szFile$ - filename to append to directory
  309. '** Returns:
  310. '**     Resulting fully qualified path name.
  311. '*************************************************************************
  312.  
  313. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  314.     IF szDir$ = "" THEN
  315.         MakePath = szFile$
  316.     ELSEIF szFile$ = "" THEN
  317.         MakePath = szDir$
  318.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  319.         MakePath = szDir$ + szFile$
  320.     ELSE
  321.         MakePath = szDir$ + "\" + szFile$
  322.     END IF
  323. END FUNCTION
  324.  
  325.  
  326. '*************************************************************************
  327. '** Purpose:
  328. '**     Registers a font.
  329. '** Arguments:
  330. '**     fontfile$ - font filename
  331. '**     fontname$ - font name.
  332. '*************************************************************************
  333.  
  334. SUB RegisterFont(fontfile$, fontname$) STATIC
  335.  
  336.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  337.  
  338.    IF AddFont(fontfile$, fontname$) = -1 THEN
  339.         j% = DoMsgBox("This font is already installed " + fontfile$ + " font.", "Viewer Font Installation", 0)
  340.    ENDIF
  341.  
  342. END SUB
  343.  
  344.  
  345. '*************************************************************************
  346. '** Purpose:
  347. '**     Registers title in VIEWER.INI
  348. '*************************************************************************
  349.  
  350. SUB ModifyViewerIni (szTitleDir$) STATIC
  351.  
  352.     '' Get the VIEWER.INI file
  353.     
  354.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  355.  
  356.     '' First register the title file, setting the Name and Path entries. 
  357.     '' We assume that the MVB file is the same directory as SETUP.EXE.
  358.     ''
  359.     '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  360.     '' following two statements for each additional file, substituting
  361.     '' the appropriate long name and MVB filename for the TitleLongName$
  362.     '' and MVBFileName$ variables.
  363.     
  364.     CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  365.     CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  366.  
  367.   
  368.     '' Now we have to register the MVB file in the [FILES] section, so 
  369.     '' Viewer can find files that are not on the path and display a 
  370.     '' special message when a file is not found.
  371.  
  372.     CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  373.  
  374.     '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  375.     '' you should copy the preceding statement for each extra title or DLL.    ''
  376.     '' Example for installing an extra title:
  377.     ''
  378.      '' CreateIniKeyValue szIni$, "FILES", "GALHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Viewer 2.0 Gallery disk.", cmoOverwrite
  379.     ''
  380.     '' Example for installing a custom DLL:
  381.  
  382. END SUB
  383.  
  384.  
  385. '*************************************************************************
  386. '** Purpose:
  387. '**     Creates program manager entries for the title
  388. '*************************************************************************
  389.  
  390. SUB ModifyProgramManager STATIC
  391.  
  392.     '' Create the program manager group
  393.  
  394.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  395.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  396.     
  397.     '' Create an entry for the title
  398.      
  399.     '' CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), "bureau.ico"), cmoOverwrite
  400.  
  401.     CreateProgmanItem ProgmanGroup$, "CheetSheets", "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), "monarch.MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), "monarch.ICO") + ",,,," + Dest$, cmoOverwrite    
  402.     '' CUSTOMIZATION: 
  403.     ''
  404.     '' To create additional Program Manager items, copy the preceding 
  405.     '' statement for each additional item, substituting the appropriate
  406.     '' Program Manager item name for ProgmanItem$ and filename for 
  407.     '' MVBFileName$.
  408.     ''
  409.     '' To display a custom icon with the Program Manager item, specify
  410.     '' the icon filename with the fourth parameter (this parameter is 
  411.     '' currently an empty string, ""). The following example specifies 
  412.     '' an icon with the same filename as the .MVB file:
  413.     ''
  414.     ''       CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".ICO"), cmoOverwrite
  415.  
  416.  
  417. END SUB
  418.  
  419.  
  420. '*************************************************************************
  421. '** Purpose:
  422. '**     Registers custom fonts with Windows.
  423. '*************************************************************************
  424.  
  425. SUB RegisterCustomFonts STATIC
  426.  
  427.     '' CUSTOMIZATION: If you install custom fonts, then add statements
  428.     '' in this routine to register the fonts with the current Windows 
  429.     '' session and to add them to the WIN.INI [Fonts] section. 
  430.     ''
  431.     '' Note that TrueType fonts can only be installed in Windows 3.1.
  432.     '' RegisterFont automatically creates the required .FOT file for 
  433.     '' TrueType fonts.
  434.     ''    
  435.     '' The following example registers a font residing in MISTRAL.TTF
  436.     '' and installs the font with the name Mistral (True Type):
  437.     '' 
  438.  
  439. END SUB
  440.  
  441.  
  442. '*************************************************************************
  443. '** Purpose:
  444. '**     Registers Windows drivers
  445. '*************************************************************************
  446.  
  447. SUB RegisterDrivers STATIC
  448.  
  449. '' CUSTOMIZATION: Video for Windows is not a standard component of
  450. '' Windows 3.1. If your title uses video, proceed as follows.
  451. ''
  452. '' 1) Add the following files to the [System Files] section of the INF file:
  453. ''
  454. ''    dispdib.dll
  455. ''    msvideo.dll
  456. ''    indeo.drv
  457. ''    mciavi.drv
  458. ''    msvidc.drv
  459. ''
  460. '' 2) Add the above files to your release directory. US versions can be 
  461. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  462. ''    German versions were not available at ship time. Please contact 
  463. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  464. ''    Compuserve Forum for further details.
  465. ''
  466. '' 3) Uncomment the following lines:
  467. ''
  468.  CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  469.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  470.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  471.  CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  472.  
  473. END SUB
  474.  
  475.